﻿using System;
using System.Collections;
using System.ComponentModel;
using PrerequisitesService.Exceptions;

namespace PrerequisitesService {

    /// <summary>
    /// 
    /// </summary>
    [RunInstaller(true)]
    public partial class PrerequisitesServiceInstaller : System.Configuration.Install.Installer {

        /// <summary>
        /// 
        /// </summary>
        /// <param name="stateSaver"></param>
        [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand)]
        public override void Install(IDictionary stateSaver) {
            try {
                base.Install(stateSaver);

                new PrerequisitesService.Services.PrerequisitesService();
            } catch(PrerequisitesException pe) {
                throw new PrerequisitesException(pe.Message);
            } catch(Exception e) {
                throw new PrerequisitesException(string.Format("An unexpected problem occurred in the Prerequisites service: {0}", e.Message));
            }
        }
    }
}